package com.uetoken.cn.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.uetoken.cn.R;
import com.uetoken.cn.bean.LanguageSelectBean;
import com.uetoken.cn.language.LanguageType;
import com.uetoken.cn.language.MultiLanguageUtil;

import java.util.List;

/**
 * @author 谢杨
 * @time 2018/7/31 14:21
 * @class 描述:语言选择适配器
 */
public class LanguageSelectAdapter extends BaseQuickAdapter<LanguageSelectBean, BaseViewHolder> {

    public LanguageSelectAdapter(int layoutResId, @Nullable List<LanguageSelectBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, LanguageSelectBean item) {
        //获取当前语言类型
        int currentLanguageType = MultiLanguageUtil.getInstance().getLanguageType();

        helper.setText(R.id.tv_item_language_select, item.getLanguage());
        //默认语言是跟随系统(也就是没有手动选择语言)
        if (currentLanguageType == LanguageType.LANGUAGE_FOLLOW_SYSTEM) {
            if (mContext.getString(R.string.str_base_language).equals(item.getLanguage())) {
                helper.setVisible(R.id.iv_item_language_select, true);
            } else {
                helper.setVisible(R.id.iv_item_language_select, false);
            }
        }else{
            if (currentLanguageType == item.getLanguageType()) {
                helper.setVisible(R.id.iv_item_language_select, true);
            } else {
                helper.setVisible(R.id.iv_item_language_select, false);
            }
        }

    }
}
